package com.monster.controller;

import com.monster.exception.AgeException;
import com.monster.exception.BusinessException;
import com.monster.exception.NameException;
import com.monster.vo.UserAddReqVO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * description:
 *
 * @author Yuanml on 2021/1/5 22:32
 */
@Controller
@RequestMapping(value = "/user")
public class UserController {

    @RequestMapping(value = "add.do", method = RequestMethod.POST)
    public String addUser(UserAddReqVO reqVO) throws BusinessException {
        if (!"zs".equals(reqVO.getName())) {
            throw new NameException("name only zs");
        }

        if (reqVO.getAge() == null || reqVO.getAge() > 80) {
            throw new AgeException("age must less than 80");
        }
        return "result";
    }
}
